#!/usr/bin/env bash
source $LIB_PATH/libui/color.sh
source $LIB_PATH/php/php.sh

#grep
each(){
    while read -r line ;
    do
        ${1//\{line\}/$line};
    done
}

eachn(){
     awk "{print \$$1}" | each "$2"
}

mps(){
    ps aux | grep "$1" | grep -v "grep $1" | grep -v '\-\-color=auto'
}

msum(){
    awk "{a[\$$1]+=1;} END {for(i in a){print a[i]\" \"i;}}"
}

#ps aux | grep app | awk '{print $2}' | each 'echo {line}'
#ps aux | grep app | eachn 2 'echo {line}'